<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>汽车入库</title>
<link rel="stylesheet" href="${ctx}/resources/layui/css/layui.css">
</head>
<body style="padding: 10px;">
	<!--  搜索条件开始 -->
	<form class="layui-form" method="post" id="searchFrm"
		lay-filter="searchFrm">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label">出租单号</label>
				<div class="layui-input-inline">
					<input type="text" name="rentid" autocomplete="off"
						class="layui-input">
				</div>
			</div>
			<div class="layui-inline">
				<button type="button" class="layui-btn layui-icon layui-icon-search"
					lay-submit="" lay-filter="doSearch">查询</button>
				<button type="reset"
					class="layui-btn layui-btn-warm layui-icon layui-icon-refresh">重置</button>
			</div>
		</div>
	</form>

	<!-- 搜索条件结束-->
	<!-- 检查单表单 开始 -->
	<blockquote class="layui-elem-quote" style="display: none;" id="checkContent">
		<h2 style="text-align: center;">检查单表单</h2>
		<hr>
		<form class="layui-form" method="post" id="checkFrm"
			lay-filter="checkFrm">
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">检查单号</label>
					<div class="layui-input-inline">
						<input type="text" name="checkid" readonly="readonly"
							autocomplete="off" class="layui-input">
					</div>
					<label class="layui-form-label">操作员</label>
					<div class="layui-input-inline">
						<input type="text" name="opername" readonly="readonly"
							autocomplete="off" class="layui-input">
					</div>
					<label class="layui-form-label">检查时间</label>
					<div class="layui-input-inline">
						<input type="text" name="checkdate" id="checkdate"
							required="required" placeholder="请选择检查时间" readonly="readonly"
							autocomplete="off" class="layui-input">
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<label class="layui-form-label">存在问题</label>
					<div class="layui-input-inline">
						<input type="text" name="problem" lay-verify="required" placeholder="请输入存在问题"
							autocomplete="off" class="layui-input">
					</div>

					<label class="layui-form-label">赔付金额</label>
					<div class="layui-input-inline">
						<input type="number" name="paymoney" lay-verify="required|number"
							placeholder="请输入赔付金额" autocomplete="off" class="layui-input">
					</div>

					<label class="layui-form-label">出租单号</label>
					<div class="layui-input-inline">
						<input type="text" name="rentid" readonly="readonly"
							autocomplete="off" class="layui-input">
					</div>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-block">
					<label class="layui-form-label">检查描述</label>
					<div class="layui-input-block">
						<textarea name="checkdesc" lay-verify="required" placeholder="请输入检查描述"
							autocomplete="off" class="layui-input layui-textarea"></textarea>
					</div>
				</div>
			</div>
			<div class="layui-form-item" style="text-align: center;">
				<div class="layui-inline">
					<button type="button"
						class="layui-btn layui-icon layui-icon-release" lay-submit=""
						lay-filter="doSubmit">保存</button>
				</div>
			</div>
		</form>
	</blockquote>
	<!-- 检查单表单 结束 -->
	<!-- 出租单-车辆-客户的信息展示 开始 -->
	<div style="padding: 5px; background-color: #F2F2F2;display: none;" id="msgContent">
		<div class="layui-row layui-col-space5">
			<div class="layui-col-md4">
				<div class="layui-card">
					<div class="layui-card-header" style="text-align: center;">车辆信息</div>
					<div class="layui-card-body" id="carmsg">
						<div id="car_carnumber"></div>
						<div id="car_cartype"></div>
						<div id="car_color"></div>
						<div id="car_price"></div>
						<div id="car_rentprice"></div>
						<div id="car_deposit"></div>
						<div id="car_description"></div>
						<div>
							车辆图片：<img style="width: 100%;height: 100%;" id="car_carimg" alt="" src="" />
						</div>
					</div>
				</div>
			</div>
			<div class="layui-col-md4">
				<div class="layui-card">
					<div class="layui-card-header" style="text-align: center;">出租单信息</div>
					<div class="layui-card-body" id="rentmsg">
						<div id="rent_rentid"></div>
						<div id="rent_price"></div>
						<div id="rent_begindate"></div>
						<div id="rent_returntime"></div>
						<div id="rent_opername"></div>
					</div>
				</div>
			</div>

			<div class="layui-col-md4">
				<div class="layui-card">
					<div class="layui-card-header" style="text-align: center;">客户信息</div>
					<div class="layui-card-body" id="customermsg">
						<div id="customer_identity"></div>
						<div id="customer_custname"></div>
						<div id="customer_sex"></div>
						<div id="customer_address"></div>
						<div id="customer_phone"></div>
						<div id="customer_career"></div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<!-- 出租单-车辆-客户的信息展示 结束 -->
	<script src="${ctx}/resources/layui/layui.js"></script>
	<script>
		var tableIns;
		var customerIdentity;
		layui.use([ 'layer', 'table', 'form', 'laydate' ], function() {
			var $ = layui.$;
			var layer = layui.layer;
			var table = layui.table;
			var form = layui.form;
			var laydate = layui.laydate;
			laydate.render({
				elem : "#checkdate",
				type : "datetime",
				position : "fixed"
			});
			//根据出租单号查询
			form.on("submit(doSearch)", function(data) {
				$.post("${ctx}/check/checkRentExist.action", data.field,
						function(result) {
							if (result.code == 1) {
								//出租单号不存在或已归还
								layer.msg(result.msg);
								$("#checkContent").hide();
								$("#msgContent").hide();
							} else {
								//未归还
								initCheckFormData(data);
								$("#checkContent").show();
								$("#msgContent").show();
							}
						}, 'json');
				return false;
			})
			//加载检查单表单信息，以及卡片面板的信息
			function initCheckFormData(data){
				$.post("${ctx}/check/initCheckFormData.action",data.field,function(result){
					//检查单
					var check = result.check;
					form.val("checkFrm",check);
					
					//车辆
					var car = result.car;
					$("#car_carnumber").html("车牌号码："+car.carnumber);
					$("#car_cartype").html("车辆类型："+car.cartype);
					$("#car_color").html("车辆颜色："+car.color);
					$("#car_price").html("购买价格："+car.price);
					$("#car_rentprice").html("出租价格："+car.rentprice);
					$("#car_deposit").html("出租押金："+car.deposit);
					$("#car_description").html("车辆描述："+car.description);
					$("#car_carimg").attr("src","${ctx}/file/downloadFile.action?path="+car.carimg);
					//出租单
					var rent = result.rent;
					$("#rent_rentid").html("出租单号："+rent.rentid);
					$("#rent_price").html("出租价格："+rent.price);
					$("#rent_begindate").html("起租时间："+rent.begindate);
					$("#rent_returntime").html("归还时间："+rent.returntime);
					$("#rent_opername").html("操作员    ："+rent.opername);
					//客户
					var customer = result.customer;
					$("#customer_identity").html("身份证号："+customer.identity);
					$("#customer_custname").html("客户姓名："+customer.custname);
					$("#customer_sex").html("客户性别："+customer.sex);
					$("#customer_address").html("客户地址："+customer.address);
					$("#customer_phone").html("客户电话："+customer.phone);
					$("#customer_career").html("客户职位："+customer.career);
				},"json");
			}
			//保存检查单信息
			form.on("submit(doSubmit)",function(data){
				$.post("${ctx}/check/addCheck.action",data.field,function(result){
					if(result.success){
						
						$("#checkContent").hide();
						$("#msgContent").hide();
					}
					layer.msg(result.message);
				},"json");
				
				
				return false;
			});
		});
	</script>
</body>
</html>